package com.ztatic.fightmode.views;

import com.ztatic.fightmode.R;
import com.ztatic.fightmode.control.ScreenHandler;
import com.ztatic.fightmode.control.ScreenHandler.Screens;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.View;

public class LogoScreen extends Screen{

	Bitmap logo;
	Paint fade;
	
	long StartTime;
	long cTime;
	
	public LogoScreen(Context context) {
		super(context);
		
		//load the logo image
		logo = BitmapFactory.decodeResource(getResources(), R.drawable.logo);
		fade = new Paint();
		
		StartTime = System.currentTimeMillis();
		//Display display = 
		
		//screen = new Rect(0, 0, 200, 200);
	}
	
	@Override
	public void onUpdate() //returns true when it has completed
	{
		cTime = System.currentTimeMillis() - StartTime;
		
		if(cTime > 4000)
		{
			//we're done here, go on to the next screen (introscreen)
			ScreenHandler.g_Handler.requestScreenChange(Screens.INTRO);
		}
	}
	
	@Override
	public void onDraw(Canvas canvas) {
		if(cTime < 1500)
			fade.setAlpha((int)((cTime) * 255 / 1500)); //0-255 over 1500 msec
		else if(cTime > 2000)
			fade.setAlpha((int)(255 - (cTime - 2000) * 255 / 1500)); //255-0 over 1500 msec
		
		canvas.drawBitmap(logo, 0, 0, fade);
	}

}
